package com.tedu.bill.demo7;

import java.util.Arrays;

/**
 * Author：毕龙
 * Date: 2024/5/7 19:39
 */
public class TestLambda4 {
    public static void main(String[] args) {
       int[] arrs = {1,3,8,5,7,2};
       Arrays.sort(arrs);
       System.out.println(Arrays.toString(arrs));
        Student[] students = {
                new Student(1,99,"linjiawei"),
                new Student(8,59,"wangpingan"),
                new Student(3,78,"zhulin"),
                new Student(9,68,"bijincao"),
                new Student(4,88,"wangshihao"),
                new Student(4,88,"wangsaao"),
                new Student(4,88,"wangqichao"),

                new Student(4,88,"wangwei")
        };
        Arrays.sort(students, (s1,s2)->{
           if(s1.getScore() < s2.getScore() ){
               return 1;
           }else if(s1.getScore() == s2.getScore() ){
                //return  s1.getAge()-s2.getAge();
               if(s1.getAge() < s2.getAge()){
                    return -1;
               }else if(s1.getAge() == s2.getAge()){
                  return s1.getName().compareTo(s2.getName());
               }else {
                   return 1;
               }
           }else{
               return -1;
           }
        });
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i]);
        }

    }
}
